package com.minigame.rpc.connection;

import io.netty.channel.Channel;

public class Connection {

    private Channel channel;


    public Connection(Channel channel)
    {
        this.channel = channel;
    }

    public Channel getChannel()
    {
        return channel;
    }


    public void setChannel(Channel channel)
    {
        this.channel = channel;
    }

    public void close()
    {
        if (channel != null)
        {
            channel.close();
        }
    }

    public boolean isActive()
    {
        return channel != null && channel.isActive();
    }

    public void writeAndFlush(Object msg)
    {
        if (channel != null && channel.isActive())
        {
            channel.writeAndFlush(msg);
        }
    }

}
